package com.study.sgu.hsp.nio;

import java.nio.IntBuffer;

/**
 * @author study
 * @version 1.0
 * @date 2020/9/26 22:38
 */
public class BasicBuffer {
    public static void main(String[] args) {
        //buffer使用
        //容量是5
        IntBuffer intBuffer = IntBuffer.allocate(5);

        //向buffer中存放数据

        intBuffer.put(10);
        intBuffer.put(11);
        intBuffer.put(12);
        intBuffer.put(13);
        intBuffer.put(14);

        //读取数据
        intBuffer.flip();//将buffer 读写切换
        while (intBuffer.hasRemaining()) {
            System.out.println(intBuffer.get());
        }


        //https://www.bilibili.com/video/BV1DJ411m7NR?p=11

    }
}
